__all__ = ['upload_file']
import requests
import json
from requests_toolbelt import MultipartEncoder


# 上传文件
def upload_file(byte):
    # 构建文件上传参数
    data = MultipartEncoder(fields={'file': ('tmp.png', byte, 'multipart/form-data')})
    # 上传文件
    res = requests.post("https://xxx.yyy.zzz", data=data, headers={'Content-Type': data.content_type})
    res_data = json.loads(res.text)
    print(res_data)
